**// Overall Mean Effect
*************
**// Panel A
*************
** // Reproduction
clear
cd "\\file\UsersW$\wrr15\Home\My Documents\My Files\REPLICATION OF ZIGRAIOVA AND HAVRANEK (2016)\REVISION FOR JOES"

log using "TABLE4.smcl", replace

use "Z&Hcompetition.dta"
set more off
**//unweighted
ivreg2 PCC, cluster (IDStudy)
**//weighted 
ivreg2 PCC [pweight=investperst], cluster (IDStudy)

**// Replication
clear
use "all.dta"
gen invvariance = 1/(SEPCC^2)
set more off
**//unweighted
ivreg2 PCC, cluster (IDStudy)
**//weighted 
ivreg2 PCC [pweight=investperst], cluster (IDStudy)
**//weighted (WLS)
ivreg2 PCC [pweight=invvariance], cluster (IDStudy)



*************
**// Panel B
*************
**// Reproduction
clear
use "Z&Hcompetition.dta"
set more off
gen double invSEPCC = 1/SEPCC
gen double lnobs = ln(Samplesize)
gen double invlnobs=1/lnobs
xtset IDStudy
eststo: xtreg t invSEPCC, fe vce(cluster IDStudy)
eststo: xtreg t invSEPCC if reviewed_journal==1, fe vce(cluster IDStudy)
eststo: xtivreg t (invSEPCC=invlnobs), fe
eststo: xtivreg t (invSEPCC=invlnobs) if reviewed_journal==1, fe
eststo: xtreg t invSEPCC [pweight=investperst], fe vce(cluster IDStudy)
eststo: xtreg t invSEPCC [pweight=investperst] if reviewed_journal==1, ///
fe vce(cluster IDStudy)

**// Replication
clear
use "all.dta"
gen invvariance = 1/(SEPCC^2)
set more off
gen double invSEPCC = 1/SEPCC
gen double lnobs = ln(Samplesize)
gen double invlnobs=1/lnobs
xtset IDStudy
eststo: xtreg t invSEPCC, fe vce(cluster IDStudy)
eststo: xtreg t invSEPCC if reviewed_journal==1, fe vce(cluster IDStudy)
eststo: xtivreg t (invSEPCC=invlnobs), fe
eststo: xtivreg t (invSEPCC=invlnobs) if reviewed_journal==1, fe
eststo: xtreg t invSEPCC [pweight=investperst], fe vce(cluster IDStudy)
eststo: xtreg t invSEPCC [pweight=investperst] if reviewed_journal==1, ///
fe vce(cluster IDStudy)
// weighted (WLS)
eststo: reg PCC SEPCC [pweight = invvariance] , vce(cluster IDStudy)
eststo: reg PCC SEPCC [pweight = invvariance] if reviewed_journal==1, vce(cluster IDStudy)


*************
**// Panel C
*************
**// Reproduction
clear
use "Z&Hcompetition.dta"
set more off
xtset IDStudy
gen double lnobs = ln(Samplesize)
**// weighted
ivreg2 PCC SEPCC dummies Hstatistic developed undeveloped Logit lnobs ///
citations firstpub quadratic Boone IFrecursive regulation OLS ///
reviewed_journal [pweight=investperst], cluster (IDStudy)

lincom  _cons + SEPCC*0 + lnobs*11.3 + IFrecursive*0.744 + ///
citations*4.164078 +firstpub*6.677419 + reviewed_journal*1 + ///
dummies*0 +  Hstatistic*0 + developed*0.3663594 + undeveloped*0.375576 + ///
Logit*0 + regulation*1 + quadratic*0 + Boone*1 + OLS*0

**// unweighted
ivreg2 PCC SEPCC  dummies Hstatistic developed undeveloped FE ///
lnobs ownership Logit SLS firstpub citations profitability ///
IFrecursive, cluster (IDStudy)

lincom _cons+SEPCC*0+dummies*0+Hstatistic*0+developed*0.3663594+ ///
undeveloped*0.375576+SLS*0.1488294+Logit*0+FE*0.229097+lnobs*11.3+ ///
IFrecursive*0.744+citations*4.164078+firstpub*6.453177+ ///
ownership*0.1655518+profitability*0.0434783

**// Replication
clear
use "all.dta"
gen invvariance = 1/(SEPCC^2)
set more off
gen double lnobs = ln(Samplesize)
xtset IDStudy
**//unweighted
ivreg2 PCC Hstatistic sampleyear RE HHI profitability ///
GMM Concentration global NPL endogeneity DtoD, cluster (IDStudy)

lincom _cons + Hstatistic*0 + sampleyear*9.472059 + RE*0.0919118 + HHI*0 + ///
profitability*0.0514706 + GMM*0.2036765  + Concentration*0 + global*0.7514706 + ///
NPL*0.1117647 + endogeneity*1 + DtoD*0.0419118 

**// weighted
ivreg2 PCC Logit citations_2019 OLS reviewed_journal Concentration ///
global  ownership  firstpub SEPCC lnobs IFrecursive_2019 DtoD ///
FE Hstatistic endogeneity sampleyear HHI dummies macro ///
[pweight=investperst], cluster (IDStudy)

lincom _cons + Logit*0 + citations_2019*4.857981 + OLS*0 + reviewed_journal*1 + ///
Concentration*0 + global*0.7514706 + ownership*0.1389706 + firstpub*8.739706 + ///
SEPCC*0 + lnobs*11.51234 + IFrecursive_2019*0.921 + DtoD*0.0419118 + ///
FE*0.2867647 + Hstatistic*0 + endogeneity*1 + sampleyear*9.472059 + HHI*0 + ///
dummies*0 + macro*0.1661765 

**// weighted (WLS)
ivreg2 PCC lnobs firstpub quadratic Lerner Zscore profit_volat ///
SEPCC GMM NPL global DtoD Hstatistic sampleyear developed undeveloped ///
someAveraged OLS citations_2019 Boone capitalization reviewed_journal ///
RE profitability Concentration endogeneity ownership Logit ///
HHI SLS dummies T macro FE IFrecursive_2019 regulation [pweight=invvariance], cluster (IDStudy)

lincom _cons + lnobs*11.51234 + firstpub*8.739706 + quadratic*0 + Lerner*0 + ///
Zscore*0.35 + profit_volat*0.0551471 + SEPCC*0 + GMM*0.2036765 + NPL*0.1117647 + global*0.7514706 ///
+ DtoD*0.0419118  + Hstatistic*0 + sampleyear*9.472059 + developed*0.3544118 ///
+ undeveloped*0.2492647 + someAveraged*0.0183824 + OLS*0 + citations_2019*4.857981 ///
+ Boone*1 + capitalization*0.0463235 + reviewed_journal*1 + RE*0.0919118 + profitability*0.0514706 + ///
Concentration*0 + endogeneity*1 + ownership*0.1389706 + Logit*0 + HHI*0 + ///
SLS*0.0852941 + dummies*0 + T*2.318156 + macro*0.1661765 + FE*0.2867647 + ///
IFrecursive_2019*0.921 + regulation*1

log close
